/**
 * Copyright (c) Tiny Technologies, Inc. All rights reserved.
 * Licensed under the LGPL or a commercial license.
 * For LGPL see License.txt in the project root for license information.
 * For commercial licenses see https://www.tiny.cloud/
 *
 * Version: 5.2.2 (2020-04-23)
 */
import store from '@/store'
var global = tinymce.util.Tools.resolve('tinymce.PluginManager')
var register = function(editor) {
  editor.addCommand('mcesaveVersion', function() {
    const url = encodeURIComponent(editor.documentBaseURI.getURI())

    const html = `<!DOCTYPE html>
      <html>
      <head>
      <meta charset="UTF-8">
      <meta name="Generator" content="EditPlus®">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
        <link type="text/css" rel="stylesheet" href="${url}tinymce/skins/ui/oxide/content.min.css">
        <link type="text/css" rel="stylesheet" href="${url}skins/content/default/content.css">
      </head>

      <body id="tinymce" class="mce-content-body ">
       ${editor.getContent()}
      </body>
      </html>`
    console.log(html)
    store.dispatch('index/addversionHtml', {
      fileid: sessionStorage.fileid,
      html
    })
  })
}
var Commands = { register: register }

var register$1 = function(editor) {
  editor.ui.registry.getAll().icons.version ||
    editor.ui.registry.addIcon(
      'version',
      '<svg t="1593525011798" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1181" width="24" height="24"><path d="M877.35808 696.4992a23.04 23.04 0 0 1 22.38464-40.27904l29.44 16.36352c37.7856 20.992 50.0992 67.28704 26.49088 102.58432a76.42624 76.42624 0 0 1-26.48576 24.2176l-378.33728 210.23744c-24.7296 13.7472-55.5264 13.7472-80.256 0L92.25728 799.3856c-37.7856-20.992-50.09408-67.28704-26.48576-102.58432a76.42624 76.42624 0 0 1 26.48576-24.21248l29.83424-16.57856a23.04 23.04 0 0 1 22.37952 40.27904l-29.82912 16.57856a30.38208 30.38208 0 0 0-10.56768 9.55392c-8.35072 12.48768-4.08064 28.54912 10.56768 36.68992l378.33216 210.24256c10.81344 6.00576 24.6784 6.00576 35.49184 0l378.33728-210.24256a30.38208 30.38208 0 0 0 10.56768-9.55904c8.35072-12.48768 4.08064-28.54912-10.56768-36.6848l-29.44512-16.36352z m-2.432-219.21792a23.04 23.04 0 0 1 22.37952-40.27904l31.88224 17.7152c37.78048 20.992 50.09408 67.28704 26.48576 102.58432a76.42624 76.42624 0 0 1-26.48576 24.2176l-378.33728 210.23744c-24.7296 13.74208-55.5264 13.74208-80.256 0l-378.33728-210.24256c-37.7856-20.992-50.09408-67.28704-26.48576-102.58432a76.42624 76.42624 0 0 1 26.48576-24.2176l31.98976-17.77152a23.04 23.04 0 1 1 22.38464 40.27904l-31.98976 17.77664a30.38208 30.38208 0 0 0-10.56768 9.55392c-8.35072 12.48768-4.08064 28.54912 10.56768 36.6848l378.33216 210.24256c10.81344 6.01088 24.6784 6.01088 35.49184 0l378.33728-210.24256a30.38208 30.38208 0 0 0 10.56768-9.55392c8.35072-12.48768 4.08064-28.54912-10.56768-36.6848l-31.87712-17.7152z m-350.52544-415.18592a28.16 28.16 0 0 0-27.35616 0L117.32992 273.1008a28.16 28.16 0 0 0 0 49.2288l379.71456 211.01056a28.16 28.16 0 0 0 27.35616 0l379.71456-211.01056a28.16 28.16 0 0 0 0-49.2288l-379.71456-211.00544z m402.0992 170.7264c35.84 19.9168 48.7424 65.11616 28.83072 100.95616a74.24 74.24 0 0 1-28.83072 28.83072l-379.71456 211.01056a74.24 74.24 0 0 1-72.12544 0L94.94528 362.60864c-35.84-19.9168-48.74752-65.11616-28.83072-100.95104a74.24 74.24 0 0 1 28.8256-28.83584L474.66496 21.81632a74.24 74.24 0 0 1 72.12544 0l379.71456 211.00544z" fill="#000000" p-id="1182" data-spm-anchor-id="a313x.7781069.0.i2" class=""></path></svg>'
    )
  editor.ui.registry.addButton('saveVersion', {
    tooltip: '保存为新版本',
    icon: 'version',
    onAction: function() {
      return editor.execCommand('mcesaveVersion')
    }
  })
  editor.ui.registry.addMenuItem('saveVersion', {
    text: '保存为新版本',
    icon: 'saveVersion',
    onAction: function() {
      return editor.execCommand('mcesaveVersion')
    }
  })
}
var Buttons = { register: register$1 }

function Plugin() {
  global.add('saveVersion', function(editor) {
    Commands.register(editor)
    Buttons.register(editor)
  })
}

Plugin()
